package base;

import lombok.extern.slf4j.Slf4j;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.retry.annotation.Retryable;

/**
 * @author Yangzhenyu06
 * @date 2021/11/2 9:57 下午
 */
@Slf4j
@EnableRetry
public class MainTest {
    private static int count = 0;

    public static void main(String[] args) {
        try {
//            ((MainTest) AopContext.currentProxy()).doExecute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @Retryable(value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 2000, multiplier = 1.5))
    private static String doExecute() throws Exception{
        System.out.println("AA");
        throw new Exception();
    }


    private static void execute() throws Exception{
        count++;
        System.out.println(count);
        if(count <2){
            throw new Exception();
        }
    }


}
